package com.sxfq.loansupermarket.backsystem.modular.basicData.service.impl;

import com.baomidou.mybatisplus.plugins.Page;
import com.sxfq.loansupermarket.backsystem.common.persistence.dao.MPayServiceMapper;
import com.sxfq.loansupermarket.backsystem.core.shiro.ShiroKit;
import com.sxfq.loansupermarket.backsystem.core.util.StringUtil;
import com.sxfq.loansupermarket.backsystem.modular.basicData.dao.PayServiceDao;
import com.sxfq.loansupermarket.backsystem.modular.basicData.entity.PayServiceInfo;
import com.sxfq.loansupermarket.backsystem.modular.basicData.entity.SearchPayServiceInfo;
import com.sxfq.loansupermarket.backsystem.modular.basicData.service.ImemberPayServiceService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Service
@Transactional
public class MemberPayServiceServiceImpl implements ImemberPayServiceService {

    @Autowired
    private PayServiceDao dao;
    @Autowired
    private RedisTemplate redisTemplate;
    @Autowired
    MPayServiceMapper mapper;

    @Override
    public List<PayServiceInfo> selectPageListByQuery(Page<PayServiceInfo> page, SearchPayServiceInfo searchInfo){
        Map<String, Object> params = new HashMap<String, Object>();
        params.put("page", page);
        if (StringUtil.isNotEmpty(searchInfo.getTreatmentUnit())) {
            params.put("treatmentUnit", searchInfo.getTreatmentUnit());
        }
        if (StringUtil.isNotEmpty(searchInfo.getFirstLevelProjectDivsd())) {
            params.put("firstLevelProjectDivsd", searchInfo.getFirstLevelProjectDivsd());
        }
        if (StringUtil.isNotEmpty(searchInfo.getIsUpperStatus())) {
            params.put("isUpperStatus", searchInfo.getIsUpperStatus());
        }
        if (StringUtil.isNotEmpty(searchInfo.getPayServiceName())) {
            params.put("payServiceName", searchInfo.getPayServiceName());
        }
        if (StringUtil.isNotEmpty(searchInfo.getIsDeal())) {
            params.put("isDeal", searchInfo.getIsDeal());
        }
        if (StringUtil.isNotEmpty(searchInfo.getIsTeethProject())) {
            params.put("isTeethProject", searchInfo.getIsTeethProject());
        }
        params.put("pay_service_info", redisTemplate.opsForList().index(ShiroKit.getUser().getAccount()+"pay_service_info",0));
        return dao.getQueryPage(page, params);
    }

}